ENTRYPOINT	= 0xC0004400

ASM		= nasm
ASMFLAGS	= -f elf -g

CC		= cc
CFLAGS		= -g -fno-stack-protector -I../include

LINK		= ld
LINKFLAGS	= -Ttext $(ENTRYPOINT)

SOURCES		= $(wildcard *.c *.asm)
OBJS		= $(patsubst %.c,%.o,$(patsubst %.asm,%.o,$(SOURCES)))
LIBS		= ../lib/*.o

TARGET		= kernel.bin

%.o : %.asm
	$(ASM) $(ASMFLAGS) -o $@ $<

kernel.bin : $(OBJS) $(LIBS)
	$(LINK) $(LINKFLAGS) -o $@ $^
	dd if=kernel.bin of=../a.img count=127 seek=4 conv=notrunc

clean :
	rm -f $(OBJS) depends

depends : $(SOURCES)
	$(CC) -M $(CFLAGS) *.c > depends

include depends
